home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gigarom 1
/
Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso
/
FILES
/
DEV
/
I-Z
/
TransSkel.cpt
/
MSkelEdit.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1987-01-07
|
3KB
|
177 lines
{ TransSkel multiple-window demonstration: TextEdit module}
{ This module handles a simple TextEdit window, in which text may be}
{ typed and standard Cut/Copy/Paste/Clear operations may be performed.}
{ Undo is not supported, nor is text scrolling.}
{ 14 June 1986 Paul DuBois}
{ 7 January 1987 Owen Hartnett }
UNIT MultiSkelEdit;
INTERFACE
USES
MultiSkelGlobs, common, TransSkelpas;
PROCEDURE EditWindInit;
PROCEDURE EditWindEditMenu (item : integer);
IMPLEMENTATION
{ edit menu item numbers }
CONST
undo = 1;
cut = 3;
copy = 4;
paste = 5;
clear = 6;
VAR
teEdit : TEHandle; { handle to text window TextEdit record }
PROCEDURE Halt;
BEGIN
TEDispose(teEdit);
CloseWindow(editWind);
END;
PROCEDURE Idle;
BEGIN
TEIdle(teEdit); { blink that cursor! }
END;
PROCEDURE key (ch : char;
mods : integer);
BEGIN
TEKey(ch, teEdit);
END;
PROCEDURE Mouse (thePt : Point;
t : longint;
mods : integer);
BEGIN
TEClick(thePt, Boolean(BitAnd(mods, shiftKey)), teEdit);
END;
{ Update text window. The update event might be in response to a}
{ window resizing. If so, resize the rects and recalc the linestarts}
{ of the text. To resize the rects, only the right edge of the}
{ destRect need be changed (the bottom is not used, and the left and}
{ top should not be changed). The viewRect should be sized to the}
{ screen.}
PROCEDURE Update (resized : Boolean);
VAR
r : Rect;
BEGIN
r := editWind^.portRect;
EraseRect(r);
r.left := r.left + 4;
r.bottom := r.bottom - 2;
r.top := r.top + 2;
r.right := r.right + 19;
IF resized THEN
BEGIN
teEdit^^.destRect.right := r.right;
teEdit^^.viewRect := r;
TECalText(teEdit);
END;
DrawGrowBox(editWind);
TEUpdate(r, teEdit);
END;
PROCEDURE Activate (active : Boolean);
BEGIN
DrawGrowBox(editWind);
IF active THEN
BEGIN
TEActivate(teEdit);
DisableItem(editMenu, undo);
END
ELSE
BEGIN
TEDeactivate(teEdit);
EnableItem(editMenu, undo);
END;
END;
{ Handle Edit menu items for text window}
PROCEDURE EditWindEditMenu;
VAR
ignore : integer;
BEGIN
CASE item OF
cut :
{ cut selection, put in TE Scrap, clear clipboard and put}
{ TE scrap in it}
BEGIN
TECut(teEdit);
ignore := ZeroScrap;
ignore := TEToScrap;
END;
copy :
{ copy selection to TE Scrap, clear clipboard and put}
{ TE scrap in it}
BEGIN
TECopy(teEdit);
ignore := zeroscrap;
ignore := TEToScrap;
END;
paste :
{ get clipboard into TE scrap, put TE scrap into edit record}
BEGIN
ignore := TEFromScrap;
TEPaste(teEdit);
END;
clear :
{ delete selection without putting into TE scrap or clipboard}
TEDelete(teEdit);
OTHERWISE
;
END;
END;
PROCEDURE EditWindInit;
VAR
r : Rect;
str : str255;
kludge : longint;
strptr : Ptr;
BEGIN
editWind := GetNewWindow(editWindRes, NIL, WindowPtr(-1));
SkelWindow(editWind, @Mouse, @Key, @Update, @Activate, NIL, @Halt, @Idle, true);
TextFont(0);
TextSize(0);
r := editWind^.portRect;
r.left := r.left + 4;
r.bottom := r.bottom - 2;
r.top := r.top + 2;
r.right := r.right - 19;
teEdit := TENew(r, r);
str := 'This is the text editing window.';
strPtr := @str;
kludge := longint(strPtr) + 1;
strPtr := Ptr(kludge);
TEInsert(strPtr, longint(str[0]), teEdit);
END;
END.